powerstep 2.2.0
Loading...
Searching...
No Matches
powerstep.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef POWERSTEP_H
29#define POWERSTEP_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
57
62
67
72#define POWERSTEP_DIR_CW 0
73#define POWERSTEP_DIR_CCW 1
74
79#define POWERSTEP_PIN_LOW_LEVEL 0
80#define POWERSTEP_PIN_HIGH_LEVEL 1
81
86#define POWERSTEP_SPEED_VERY_SLOW 0
87#define POWERSTEP_SPEED_SLOW 1
88#define POWERSTEP_SPEED_MEDIUM 2
89#define POWERSTEP_SPEED_FAST 3
90#define POWERSTEP_SPEED_VERY_FAST 4
91 // powerstep_set
93
98
103
108#define POWERSTEP_MAP_MIKROBUS( cfg, mikrobus ) \
109 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
110 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
111 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
112 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM );
113 // powerstep_map // powerstep
116
121typedef struct
122{
123 digital_out_t dir;
124 digital_out_t rst;
125 digital_out_t en;
126 digital_out_t step;
127
129
134typedef struct
135{
136 pin_name_t dir;
137 pin_name_t rst;
138 pin_name_t en;
139 pin_name_t step;
140
142
153
159
170
185
195
205
216void powerstep_set_direction ( powerstep_t *ctx, uint8_t dir );
217
227
238void powerstep_set_rst_pin ( powerstep_t *ctx, uint8_t state );
239
249
260void powerstep_set_step_pin ( powerstep_t *ctx, uint8_t state );
261
277void powerstep_drive_motor ( powerstep_t *ctx, uint32_t steps, uint8_t speed );
278
279#ifdef __cplusplus
280}
281#endif
282#endif // POWERSTEP_H
283 // powerstep
285
286// ------------------------------------------------------------------------ END
void powerstep_drive_motor(powerstep_t *ctx, uint32_t steps, uint8_t speed)
Power Step driver motor function.
void powerstep_switch_direction(powerstep_t *ctx)
Power Step switch direction function.
void powerstep_enable_device(powerstep_t *ctx)
Power Step enable device function.
void powerstep_set_rst_pin(powerstep_t *ctx, uint8_t state)
Power Step set rst pin function.
void powerstep_reset_device(powerstep_t *ctx)
Power Step reset device function.
void powerstep_set_direction(powerstep_t *ctx, uint8_t dir)
Power Step set direction function.
void powerstep_cfg_setup(powerstep_cfg_t *cfg)
Power Step configuration object setup function.
void powerstep_set_step_pin(powerstep_t *ctx, uint8_t state)
Power Step set step pin function.
void powerstep_disable_device(powerstep_t *ctx)
Power Step disable device function.
err_t powerstep_init(powerstep_t *ctx, powerstep_cfg_t *cfg)
Power Step initialization function.
powerstep_return_value_t
Power Step Click return value data.
Definition powerstep.h:148
@ POWERSTEP_ERROR
Definition powerstep.h:150
@ POWERSTEP_OK
Definition powerstep.h:149
Power Step Click configuration object.
Definition powerstep.h:135
pin_name_t step
Definition powerstep.h:139
pin_name_t dir
Definition powerstep.h:136
pin_name_t en
Definition powerstep.h:138
pin_name_t rst
Definition powerstep.h:137
Power Step Click context object.
Definition powerstep.h:122
digital_out_t step
Definition powerstep.h:126
digital_out_t en
Definition powerstep.h:125
digital_out_t rst
Definition powerstep.h:124
digital_out_t dir
Definition powerstep.h:123